<%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2018/7/27
  Time: 10:35
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<html>
<head>
    <title>入库新增</title>


</head>

<body>


<form  action="" class="form-horizontal" role="form" id="myForm" >
    <div class="modal fade bs-example-modal-lg" id="myModal"  tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" aria-hidden="true" data-backdrop="static">
        <!--  定义模态框，过渡效果为淡入，id为myModal,tabindex=-1可以禁用使用tab切换，aria-labelledby用于引用模态框的标题，aria-hidden=true保持模态框在触发前窗口不可见  -->
        <div class="modal-dialog modal-lg">
            <!--  显示模态框对话框模型（若不写下一个div则没有颜色）  -->
            <div class="modal-content">
                <!--  显示模态框白色背景，所有内容都写在这个div里面  -->

                <div class="btn-info modal-header">
                    <!--  模态框标题  -->
                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                    <!--  关闭按钮  -->
                    <h4>入库单添加</h4>
                    <!--  标题内容  -->
                </div>

                <div class="modal-body">
                    <!--  模态框内容，我在此处添加一个表单 -->
                    <%--<form id="user-form"  class="form-horizontal">--%>

                    <div class="form-group">
                        <label for="uname" class="col-sm-2 control-label">入库单号/编号</label>
                        <div class="col-sm-9">
                            <input type="text"  name="cremark1" class="form-control" placeholder="入库单号/编号"/>
                        </div>
                    </div>


                    <div class="form-group">
                        <label  class="col-sm-2 control-label">交货单位</label>
                        <div class="col-sm-9">
                            <select class="js-data-example-ajax form-control" name="gocompany" id="gocompany">
                            </select>
                        </div>
                    </div>


                    <div class="form-group">
                        <label  class="col-sm-2 control-label">入库类型</label>
                        <div class="col-sm-9">
                            <select class="js-data-example-ajax form-control" name="gotype">
                                <option value="一般入库">一般入库</option>
                                <option value="借调入库">借调入库</option>
                            </select>
                        </div>
                    </div>

                    <div class="form-group">
                        <label  class="col-sm-2 control-label">经办人</label>
                        <div class="col-sm-9">
                            <select class="js-data-example-ajax form-control" name="singleperson" id="singleperson">
                                <option value="1">张三</option>
                                <option value="2">李四</option>
                                <option value="3">王五</option>
                                <option value="4">赵柳</option>
                            </select>
                        </div>
                    </div>

                    <div class="form-group">
                        <label  class="col-sm-2 control-label">收货人</label>
                        <div class="col-sm-9">
                            <select class="js-data-example-ajax form-control" name="consignee">
                                <option value="1">张三</option>
                                <option value="2">李四</option>
                                <option value="3">王五</option>
                                <option value="4">赵柳</option>
                            </select>
                        </div>
                    </div> 
                    <div class="form-group">
                        <label  class="col-sm-2 control-label">保管员</label>
                        <div class="col-sm-9">
                            <select class="js-data-example-ajax form-control" name="custodian">
                                <option value="1">张三</option>
                                <option value="2">李四</option>
                                <option value="3">王五</option>
                                <option value="4">赵柳</option>
                            </select>
                        </div>
                    </div> 

                     <div class="form-group">
                        <label  class="col-sm-2 control-label">入库时间</label>
                        <div class="col-sm-9">
                            <div class='input-group date' id='datetimepicker2' >
                                <input type='text' class="form-control" name="time"/>
                                <span class="input-group-addon">
                                    <span class="glyphicon glyphicon-calendar"></span>
                                </span>
                            </div>
                        </div>
                    </div> 
                    
                    <div class="form-group">
                        <label  class="col-sm-2 control-label">申请单</label>
                        <div class="col-sm-9">
                        	<input type="hidden" name="cremark2">
                            
                            <select id="sel_menu2" multiple="multiple" class="js-states form-control" >
                            </select>
                        </div>
                    </div> 

                </div>

                <div class="modal-footer">
                    <!--  模态框底部样式，一般是提交或者确定按钮 -->
                    <button type="button" class="btn btn-info" id="submit">确定</button>
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                </div>

            </div><!-- /.modal-content -->
        </div>
    </div> <!-- /.modal -->
</form>

<script>
    $(function () {
    	
    	 //多选
        $("#sel_menu2").select2({
        	 language: "zh-CN", //设置 提示语言
	       	 width: "100%", //设置下拉框的宽度
	         placeholder: "请选择",
	         tags: true,
	         maximumSelectionLength: 3,  //设置最多可以选择多少项
             allowClear: true,//允许清空	
        });
    	 
    	 /**
    	  * 
    	  */
    	 $.ajax({
    		 type:'post',
    		 url:'godown/listOrder.do',
    		 success:function(data) {
    			 
    			 for (var i = 0; i < data.length; i++) {
						
     				$("#sel_menu2").append($("<option>", {value: data[i].orderId, text: data[i].name}));
				} 
    		 }
    		 
    	 });
    	 
    	 $.ajax({
    		 type:'post',
    		 url:'godown/selectSupper.do',
			 success:function(data) {
    			 
    			 for (var i = 0; i < data.length; i++) {
						
     				$("#gocompany").append($("<option>", {value: data[i].supplierId, text: data[i].supplierName}));
				} 
    		 }
    	 });
    	 
    	 
    	 $('input[name="cremark1"]').val(new Date().getTime());
    	 
    	
    	toastr.options.positionClass = 'toast-top-center';

        $('#datetimepicker2').datetimepicker({
            format: 'YYYY-MM-DD HH:mm:ss',
            locale: moment.locale('zh-cn')
        });
        
        $('#submit').click(function() {
        	
        	$('input[name="cremark2"]').val($('#sel_menu2').val());
        	
        	$.ajax({
        		type:"POST",
        		url:'godown/insertGoDownEntry.do',
        		data: $('#myForm').serialize(),
        		success:function(data) {
        			
        			if(data.success) {
        				
        				$("#myModal").modal('hide');
        				
        				toastr.success("添加成功!"); 
        			}else {
        				
        			}
        			
        		}
        	}); 
        	
        });
        
    });
    
   
</script>

</body>
</html>

